package com.alex.controller.Ai_Writing_Assistant;

import co.elastic.clients.elasticsearch._types.query_dsl.MatchQuery;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import com.alex.common.beans.ResultBean;
import com.alex.service.AllQueryBasicService;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RequestMapping("/ai_writing_assistant")
@RestController
public class Ai_Writing_Assistant_Controller extends AllQueryBasicService {

    @GetMapping(value = "ai_writing_assistant")
    public ResultBean<Object> auth_net_work(String param, Integer page, Integer limit) {
        Query query = MatchQuery.of(i -> i.field("str").query(param))._toQuery();
        List<Integer> integers = checkPage(page, limit);
        try {
            return new ResultBean<>(allQueryYuLiao(query, integers.get(0), integers.get(1)));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new ResultBean<>(null);
    }


}
